<?php
namespace App\Listener;

use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Event\Annotation\Listener;

use App\Repository\UserLogRepository;

/**
 * @Listener 
 */
class UserLogListener implements ListenerInterface
{
    public function listen(): array
    {
        return [
            \App\Event\User\MoneyWalletEvent::class,
            \App\Event\User\MoneyWalletRedEvent::class,
            \App\Event\User\MoneyDiscountEvent::class,
            \App\Event\User\MoneyFullEvent::class,
            \App\Event\User\MoneyEvent::class,
        ];
    }
    
    // 记录日志
    public function process($event)
    {
        UserLogRepository::make()->create($event->user, $event->log());
    }
}